package sort;

import com.alibaba.fastjson.JSONObject;
import org.algorithm_visualizer.*;

import java.sql.SQLOutput;
import java.util.Arrays;

public class BubbleSort {

    public static void main(String[] args) {
        int[] array = new int[]{3,2,7,5,4,8,8,9,6};
        System.out.println(JSONObject.toJSONString(array));
        bubble(array);
        System.out.println(JSONObject.toJSONString(array));
    }



   private static void bubble(int[] array){
       for(int i = 0; i < array.length; i++){
           System.out.println("i : " + i + ", array["+i+"] : " + array[i]);
           for(int j = 0; j < array.length; j++){
               System.out.println("j : " + j + ", array["+j+"] : " + array[j]);
               if(array[j] > array[i]){
                   int temp = array[i];
                   array[i] = array[j];
                   array[j] = temp;

               }
               System.out.println(JSONObject.toJSONString(array));
           }
           System.out.println("=======================================");
       }
   }
}
